-
Notifications
You must be signed in to change notification settings - Fork 176
Refactor errors, add tests, improve code style #370
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…ndling and annotations. - Encapsulate exception handling with `toMcpException`. - Move `AbstractTransport` to a separate file. - Add `null` as the default value for optional fields in MCP types. - Rename `McpError` to `McpException` for clarity and better usability. Move to a separate file. Use it in some places instead of IllegalStateException - Gradle: Downgrade `kotest` assertions library to support JDK 8. - Improve `ServerPromptsTest` cases with new scenarios and assertions. - Reformat KDocs and fix Detekt issues - Add additional `@Suppress` annotations to improve readability and control warnings.
807e4a5 to
953acce
Compare
| * corresponding [_onClose], [_onError] and [_onMessage] properties to use for an implementation. | ||
| */ | ||
| @Suppress("PropertyName") | ||
| public abstract class AbstractTransport : Transport { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved to separate file
| client.getPrompt(GetPromptRequest("test-prompt-with-custom-handler")) shouldBe expectedPromptResult | ||
|
|
||
| client.listPrompts() shouldNotBeNull { | ||
| prompts shouldContainExactly listOf(testPrompt) | ||
| nextCursor shouldBe null | ||
| _meta shouldBe EmptyJsonObject | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We SHOULD verify that the prompt was actually added
| client.listPrompts() shouldNotBeNull { | ||
| prompts.shouldBeEmpty() | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually verify, that prompts were removed
| @Test | ||
| fun `removePrompt should throw when prompts capability is not supported`() = runTest { | ||
| @Nested | ||
| inner class NoPromptsCapabilitiesTests { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
group negative scenarios
| verify { | ||
| rule { | ||
| minBound(65) | ||
| minBound(75) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rise the bar
tiginamaria
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks nice! Thank you
|
set to draft to avoid conflicts with @devcrocod's changes |
|
Use #376 instead |
Refactor MCP Protocol and related classes for improved exception handling and annotations.
nullas the default value for optional fields in MCP types.McpErrortoMcpExceptionfor clarity and better usability. Move to a separate file. Use it in some places instead of IllegalStateException. CreateMcpExceptionfromJSONRPCErrorwithJSONRPCError.toMcpException()AbstractTransportto a separate file.ServerPromptsTestcases with new scenarios and assertions.kotestassertions library to support JDK 8.@Suppressannotations to improve readability and control warnings.Motivation and Context
Improve ServerPromptsTest;
Provide default values to simplify API usage.
To make use of MCP-specific errors instead of generic
IllegalStateExceptionCleanup code to make issues visible in Detekt.
How Has This Been Tested?
Unit/Integraiton tests, regression tests
Breaking Changes
getPrompt throws new
McpException(exMcpError) instead ofIllegalStateException.Types of changes
Checklist
Additional context